package simple

import "strings"

func isPalindrome(s string) bool {

	s = strings.ToLower(s)
	i, j := 0, len(s)-1
	for i < j {
		if !isValidPalindrome(s[i]) {
			i++
			continue
		}
		if !isValidPalindrome(s[j]) {
			j--
			continue
		}
		if s[i] != s[j] {
			return false
		}

		i++
		j--
	}

	return true
}

func isValidPalindrome(c byte) bool {
	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
}
